home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 9 / Night Owl CD-ROM (NOPV9) (Night Owl Publisher) (1993).ISO / 041a / wr06003.zip / WR06003.CMD next >
OS/2 REXX Batch file  |  1993-01-27  |  20KB  |  496 lines

  1. /****************************************************************************
  2.  
  3.         Module Name             = WR06003.CMD
  4.  
  5.         Descriptive Name        = SelectPak 3 (Database Utilities)
  6.                                   install tool
  7.  
  8.         Copyright               = 04G1049  (C) Copyright IBM Corp. 1988, 1991.
  9.                                   All rights reserved.
  10.                                   US Government Users Restricted Rights -
  11.                                   Use, duplication or disclosure restricted by
  12.                                   GSA ADP Schedule Contract with IBM Corp.
  13.  
  14.                                   Licensed Materials - Property of IBM
  15.  
  16.         Function                = Installation tool for SelectPak 003
  17.  
  18.         Operating System        = OS/2 Extended Services
  19.  
  20. ****************************************************************************/
  21.  
  22. signal on halt          /* call HALT: routine on CTRL-BREAK */
  23. "echo off"
  24.  
  25. /*************************************************/
  26. /* Read in command line arguements if they exist */
  27. /*************************************************/
  28. parse upper arg Base_Drive Update_Drive Backed .
  29.  
  30.  
  31. /***********************************************************/
  32. /* Verify that the Database SelectPak message file exists  */
  33. /***********************************************************/
  34. MSG_FILE = stream('WR06DBM.MSG' , 'c' , 'query exists')
  35. if MSG_FILE = "" then
  36.         do
  37.         say " ERROR: could not find message file WR06DBM.MSG "
  38.         signal End
  39.         end
  40.  
  41. /***************************************************/
  42. /* Read the message file into an array of messages */
  43. /***************************************************/
  44. do while lines(MSG_FILE) \= 0    /* While not at EOF  */
  45.  
  46.         text_of_message = MSG_Parse(linein(MSG_FILE))
  47.         MSG.message_number = text_of_message
  48.  
  49. end                              /* End of While loop */
  50.  
  51.  
  52. /**************************************/
  53. /*  Close the message file            */
  54. /**************************************/
  55. RC = stream('WR06DBM.MSG' , 'c' , 'close')
  56.  
  57. start:
  58. "cls"
  59.  
  60. /****************************************/
  61. /*  One possible input parameter is '?' */
  62. /*  Display the help panel in this case */
  63. /****************************************/
  64. if Base_Drive = "?" then signal syntax
  65.  
  66. /*************************/
  67. /*  Introductory panel   */
  68. /*************************/
  69. say
  70. say
  71. say centre(MSG.42,50)
  72. say centre(Create_MSG(MSG.01,'003'),50)
  73. say centre(MSG.02,50)
  74. say
  75. say
  76.  
  77. /***************************************************/
  78. /* The Base Drive letter is the Drive letter that  */
  79. /* contains the Base Operating System.             */
  80. /***************************************************/
  81. get_Base_Drive:
  82. if Base_Drive \= "" then signal got_Base_Drive
  83. call charout ,"  "MSG.03" "
  84. parse upper linein Base_Drive
  85. if Base_Drive = "" then
  86.         do
  87.         say "  "MSG.04
  88.         signal get_Base_Drive
  89.         end
  90.  
  91. got_Base_Drive:
  92. /*************************************************/
  93. /* Verify that the \OS2\INSTALL directory exists */
  94. /* on the drive specified by the user            */
  95. /*************************************************/
  96. "dir "Base_Drive":\OS2\INSTALL                                   >  NUL  2>>&1"
  97. if RC \= 0 then
  98.         do
  99.         say
  100.         say "  "Create_MSG2(MSG.05,Base_Drive,'\OS2\INSTALL')
  101.         say "  "Create_MSG(MSG.06,'\OS2\INSTALL')
  102.         say "  "MSG.07
  103.         parse linein ignore
  104.         Base_Drive = ""
  105.         signal get_Base_Drive
  106.         end
  107.  
  108. /***************************************************/
  109. /* The log varible will contain the full path name */
  110. /* of the output log.  The output log will contain */
  111. /* any error messages from this installation       */
  112. /***************************************************/
  113. LOG = ""Base_Drive":\OS2\INSTALL\WR06003.LOG"
  114. say
  115. say "  "Create_MSG(MSG.08,LOG)
  116. say
  117. say
  118.  
  119. /******************************************************/
  120. /* The Update Drive letter is the letter of the Drive */
  121. /* containing the Database system directory that      */
  122. /* you wish to upgrade.                               */
  123. /******************************************************/
  124. get_Update_Drive:
  125. if Update_Drive \= "" then signal got_Update_Drive
  126. call charout ,"  "MSG.09" "
  127. parse upper linein Update_Drive
  128. if Update_Drive = "" then
  129.         do
  130.         say "  "MSG.04
  131.         signal get_Update_Drive
  132.         end
  133.  
  134. got_Update_Drive:
  135. /*************************************************/
  136. /* Verify that the \SQLLIB directory exists      */
  137. /* on the drive specified by the user            */
  138. /*************************************************/
  139. "dir "Update_Drive":\SQLLIB                                      >  NUL  2>>&1"
  140. if RC \= 0 then
  141.         do
  142.         say
  143.         say "  "Create_MSG2(MSG.05,Update_Drive,'\SQLLIB')
  144.         say "  "Create_MSG(MSG.06,'\SQLLIB')
  145.         say "  "MSG.07
  146.         parse linein ignore
  147.         Update_Drive = ""
  148.         signal get_Update_Drive
  149.         end
  150.  
  151. /***********************************************************/
  152. /* Display to the user, the directory that will be updated */
  153. /***********************************************************/
  154. say
  155. say "  "Create_MSG2(MSG.12,Update_Drive,'SQLLIB')
  156. say
  157.  
  158. Backup:
  159. /***********************************************************/
  160. /* Ask the user if they would like the old files to be     */
  161. /* backed up to the current directory.                     */
  162. /***********************************************************/
  163. say
  164. say "  "Create_MSG(MSG.13,'0.57')
  165. call charout , "  "Create_MSG(MSG.14,Backed)
  166.  
  167. if Backed \= "" then signal got_Backup
  168. parse upper linein Backed
  169. got_Backup:
  170. if Backed  = "0" then signal verify
  171. if Backed \= "1" then              /* Only 0 and 1 are acceptable inputs */
  172.         do
  173.         say
  174.         say "  "MSG.15
  175.         Backed = ""
  176.         signal Backup
  177.         end
  178.  
  179. verify:
  180. /*************************************************/
  181. /* Ask for verification of the input parameters. */
  182. /* This is done even if the user is using the    */
  183. /* command line interface.                       */
  184. /*************************************************/
  185. say
  186. say
  187. call charout ,"  "MSG.16" "
  188. parse upper linein Verified
  189. if Verified  = "0" then        /* If the user answers NO to verification */
  190.         do                     /* then reset all of the input parameters */
  191.         Base_Drive = ""        /* and go back to the start.              */
  192.         Update_Drive = ""
  193.         Backed = ""
  194.         Verified = ""
  195.         signal start
  196.         end
  197.  
  198. if Verified \= "1" then        /* Only 0 and 1 are acceptable inputs */
  199.         do
  200.         say
  201.         say "  "MSG.15
  202.         Verified = ""
  203.         signal verify
  204.         end
  205. say
  206.  
  207. /*****************************************************************************/
  208. /*                                                                           */
  209. /* Set up the following variables:                                           */
  210. /* SYSLEVEL: The fully qualified path name of the SYSLEVEL file for database */
  211. /* SQL_PATH: The fully qualified path name of the SQLLIB        directory    */
  212. /* DLL_PATH: The fully qualified path name of the SQLLIB\DLL    directory    */
  213. /* REQ_PATH: The fully qualified path name of the SQLLIB\REQDLL directory    */
  214. /*                                                                           */
  215. /*****************************************************************************/
  216.  
  217. SYSLEVEL = Update_Drive":\SQLLIB\SYSLEVEL.SQL"
  218. SQL_PATH = Update_Drive":\SQLLIB"
  219. DLL_PATH = Update_Drive":\SQLLIB\DLL"
  220. REQ_PATH = Update_Drive":\SQLLIB\REQDLL"
  221.  
  222.  
  223. /*******************************************************************/
  224. /* Check to see that the customer has WR06000 or WR06010 installed */
  225. /* by reading the syslevel file.                                   */
  226. /*******************************************************************/
  227. firstline = linein(SYSLEVEL)
  228.  
  229. /*****************************************************/
  230. /* Close the syslevel file so that it can be updated */
  231. /*****************************************************/
  232. RC = stream(SYSLEVEL,'c','close')
  233.  
  234. /************************************************************/
  235. /* CSD_LEVEL will contain the current level of service and  */
  236. /* PAK_TYPE will tell us weather this installation was from */
  237. /* a server package or requester package.                   */
  238. /************************************************************/
  239. csd_level = substr(firstline,45,7)
  240. pak_type  = substr(firstline,101,8)
  241.  
  242. /**************************************************************/
  243. /* Only allow this installation if the users current CSD      */
  244. /* level is WR06000 ( ES 1.0 ) or WR06010 ( ES 1.0 plus this  */
  245. /* first round of SelectPaks )                                */
  246. /**************************************************************/
  247. if csd_level \= 'WR06010' & csd_level \= 'WR06000' then
  248. do
  249.         say
  250.         say "  "MSG.17
  251.         say "  "MSG.18
  252.         say "  "MSG.19
  253.         say
  254.         signal End
  255. end
  256.  
  257. /***********************************************************/
  258. /*  If the initial installation was from a server package, */
  259. /*  then install SYSLEVEL.SQS as SYSLEVEL.SQL.  Otherwise  */
  260. /*  install SYSLEVEL.SQC as SYSLEVEL.SQL.                  */
  261. /***********************************************************/
  262. if pak_type = 'with Ser' then SYSLVL_FILE = SYSLEVEL.SQS
  263.                          else SYSLVL_FILE = SYSLEVEL.SQC
  264.  
  265. "echo.                                                           >> "LOG" 2>>&1"
  266. "echo " centre(MSG.42,50)                                     "  >> "LOG" 2>>&1"
  267. "echo " centre(Create_MSG(MSG.01,'003'),50)                   "  >> "LOG" 2>>&1"
  268. "echo.                                                           >> "LOG" 2>>&1"
  269. "echo.                                                           >> "LOG" 2>>&1"
  270. "echo.                                                           >> "LOG" 2>>&1"
  271.  
  272. /***********************************************************************/
  273. /* If the user had chosen to backup the old version of the files,      */
  274. /* then copy the files that will be changing from the SQLLIB directory */
  275. /* to the current directory.                                           */
  276. /***********************************************************************/
  277. if Backed  = "0" then signal skip_Backup
  278. "echo "MSG.20 SQL_PATH"\SQLUDPRO.EXE                             >>"LOG" 2>>&1"
  279. "copy "SQL_PATH"\SQLUDPRO.EXE                                    >>"LOG" 2>>&1"
  280. "echo "MSG.20 SQL_PATH"\SQLUEXIT.EX1                             >>"LOG" 2>>&1"
  281. "copy "SQL_PATH"\SQLUEXIT.EX1                                    >>"LOG" 2>>&1"
  282. "echo "MSG.20 SQL_PATH"\SQLUEXIT.EX4                             >>"LOG" 2>>&1"
  283. "copy "SQL_PATH"\SQLUEXIT.EX4                                    >>"LOG" 2>>&1"
  284. "echo "MSG.20 SQL_PATH"\SQLUEXPM.EXE                             >>"LOG" 2>>&1"
  285. "copy "SQL_PATH"\SQLUEXPM.EXE                                    >>"LOG" 2>>&1"
  286. "echo "MSG.20 SQL_PATH"\SQLUHCDB.EXE                             >>"LOG" 2>>&1"
  287. "copy "SQL_PATH"\SQLUHCDB.EXE                                    >>"LOG" 2>>&1"
  288. "echo "MSG.20 SQL_PATH"\SQLUHCOP.EXE                             >>"LOG" 2>>&1"
  289. "copy "SQL_PATH"\SQLUHCOP.EXE                                    >>"LOG" 2>>&1"
  290. "echo "MSG.20 SQL_PATH"\SYSLEVEL.SQL                             >>"LOG" 2>>&1"
  291. "copy "SQL_PATH"\SYSLEVEL.SQL SYSLVOLD.SQL                       >>"LOG" 2>>&1"
  292.  
  293. "echo "MSG.20 DLL_PATH"\SQLUB.DLL                                >>"LOG" 2>>&1"
  294. "copy "DLL_PATH"\SQLUB.DLL                                       >>"LOG" 2>>&1"
  295.  
  296. "echo "MSG.20 REQ_PATH"\SQLUB.DLL to SQLUBREQ.DLL                >>"LOG" 2>>&1"
  297. "copy "REQ_PATH"\SQLUB.DLL SQLUBREQ.DLL                          >>"LOG" 2>>&1"
  298. skip_Backup:
  299.  
  300.  
  301. /*****************************************************************************/
  302. /* Determine what type of Database configuration exists.                     */
  303. /* ie. is it a Server, Requester, Standalone or Requester w/ local databases */
  304. /*****************************************************************************/
  305. "WR06DBM"
  306. nodetype = RC
  307. "echo "MSG.44 " " nodetype "                                     >>"LOG" 2>>&1"
  308. "echo "MSG.45 "                                                  >>"LOG" 2>>&1"
  309.  
  310.  
  311. /***************************************************************************/
  312. /* Unzip the SQLLIB files   -n means only unzip newer files                */
  313. /*                          -d means create directories stored in ZIP file */
  314. /***************************************************************************/
  315. "PKUNZIP2 -n -d WR06003.SPK "SQL_PATH"\                          >>"LOG" 2>>&1"
  316. if RC = 0 then signal Zip_Done1
  317.  
  318. if RC = 11 then  /* Make a note in the log if no files were unziped */
  319.         do
  320.         say
  321.         say "  "Create_MSG(MSG.21,SQL_PATH)
  322.         signal Zip_Done1
  323.         end
  324.  
  325. /****************************************************************************/
  326. /* If there were any errors then tell the user that there were problems.    */
  327. /****************************************************************************/
  328. say "  "MSG.22
  329. say "  "Create_MSG(MSG.23,LOG)
  330. say "  "
  331. say "  "MSG.07
  332. parse linein ignore
  333.  
  334. Zip_Done1:
  335. /****************************************************************/
  336. /*  Copy and delete files based on nodetype of the installation */
  337. /****************************************************************/
  338. if nodetype = 2 then do
  339.     "echo copying  SQLUBREQ.DLL to SQLUB.DLL                     >>"LOG" 2>>&1"
  340.     "copy "DLL_PATH"\SQLUBREQ.DLL "DLL_PATH"\SQLUB.DLL           >>"LOG" 2>>&1"
  341.     "echo deleting SQLUDPRO.EXE, SQLUEXIT.EX1, SQLUEXIT.EX4      >>"LOG" 2>>&1"
  342.     "del "SQL_PATH"\SQLUDPRO.EXE                                 >>"LOG" 2>>&1"
  343.     "del "SQL_PATH"\SQLUEXIT.EX1                                 >>"LOG" 2>>&1"
  344.     "del "SQL_PATH"\SQLUEXIT.EX4                                 >>"LOG" 2>>&1"
  345.     end
  346. else do
  347.     "echo copying  SQLUBSS.DLL to SQLUB.DLL                      >>"LOG" 2>>&1"
  348.     "copy "DLL_PATH"\SQLUBSS.DLL  "DLL_PATH"\SQLUB.DLL           >>"LOG" 2>>&1"
  349.     end
  350.  
  351. "echo deleting SQLUBREQ.DLL, SQLUBSS.DLL                         >>"LOG" 2>>&1"
  352. "del "DLL_PATH"\SQLUBREQ.DLL                                     >>"LOG" 2>>&1"
  353. "del "DLL_PATH"\SQLUBSS.DLL                                      >>"LOG" 2>>&1"
  354.  
  355. /**********************************************************************/
  356. /* Update the SYSLEVEL file to indicate a SelectPak has been applied  */
  357. /**********************************************************************/
  358. "echo "MSG.24"                                                   >>"LOG" 2>>&1"
  359. "attrib -r "SQL_PATH"\SYSLEVEL.SQL                               >  NUL  2>>&1"
  360. "copy "SQL_PATH"\"SYSLVL_FILE     SQL_PATH"\SYSLEVEL.SQL         >>"LOG" 2>>&1"
  361. "del "SQL_PATH"\SYSLEVEL.SQS                                     >>"LOG" 2>>&1"
  362. "del "SQL_PATH"\SYSLEVEL.SQC                                     >>"LOG" 2>>&1"
  363. "attrib +r "SQL_PATH"\SYSLEVEL.SQL                               >  NUL  2>>&1"
  364.  
  365.  
  366.  
  367. REQDLL:
  368. /***********************************************************/
  369. /* If the REQDLL directory exists and has files in it then */
  370. /* update them with the ones in the ZIP file               */
  371. /***********************************************************/
  372. "dir "REQ_PATH"                                                  >  NUL  2>>&1"
  373. if RC \= 0 then signal Done
  374.  
  375. "PKUNZIP2 -n WR06003.SPK DLL\SQLUBREQ.DLL "REQ_PATH"              >>"LOG" 2>>&1"
  376. if RC = 0 then signal Zip_Done2
  377.  
  378. /*****************************************************/
  379. /* If there were no files to unpack, notify the user */
  380. /*****************************************************/
  381. if RC = 11 then
  382.         do
  383.         say
  384.         say "  "Create_MSG(MSG.21,REQ_PATH)
  385.         signal Zip_Done2
  386.         end
  387.  
  388. /****************************************************************************/
  389. /* If there were any errors then tell the user that there were problems.    */
  390. /****************************************************************************/
  391. say "  "MSG.22
  392. say "  "Create_MSG(MSG.23,LOG)
  393. say
  394. say "  "MSG.07
  395. parse linein ignore
  396.  
  397.  
  398. Zip_Done2:
  399. /*******************************************************************/
  400. /* Clean up the REQDLL directory by renaming the appropriate files */
  401. /*******************************************************************/
  402.  
  403. if nodetype = 1 || nodetype = 3 then do
  404.         "echo copying  SQLUBREQ.DLL to SQLUB.DLL in REQDLL       >>"LOG "2>>&1"
  405.         "copy "REQ_PATH"\SQLUBREQ.DLL  "REQ_PATH"\SQLUB.DLL      >>"LOG "2>>&1"
  406.         "echo deleting SQLUBREQ.DLL in REQDLL                    >>"LOG "2>>&1"
  407.         "del "REQ_PATH"\SQLUBREQ.DLL                             >>"LOG "2>>&1"
  408.         end
  409. else do
  410.         "echo deleting SQLUBREQ.DLL in REQDLL                    >>"LOG "2>>&1"
  411.         "del "REQ_PATH"\SQLUBREQ.DLL                             >>"LOG "2>>&1"
  412.         end
  413.  
  414. Done:
  415.  
  416. /**************************************************************/
  417. /* The installation is now complete, inform the user and exit */
  418. /**************************************************************/
  419. say
  420. say centre(Create_MSG(MSG.25,'WR06003'),50)
  421. say
  422. signal End
  423.  
  424. /***********************************************************/
  425. /* This routine will be called if the user uses CTRL-BREAK */
  426. /***********************************************************/
  427. HALT:
  428. say
  429. say
  430. say MSG.26
  431. say MSG.27
  432. say
  433. signal End
  434.  
  435. /* Help panel */
  436. syntax:
  437. say
  438. say "  "Create_MSG(MSG.28,'WR06003')
  439. say
  440. say "  "MSG.29
  441. say "      "MSG.30
  442. say "         "Create_MSG(MSG.31,'\OS2\INSTALL')
  443. say "      "MSG.32
  444. say "         "Create_MSG(MSG.31,'\SQLLIB')
  445. say "      "MSG.34
  446. say "         "Create_MSG(MSG.35,'0.57')
  447. say "      "MSG.36
  448. say "         "MSG.37
  449. say
  450. say
  451. say "  "Create_MSG(MSG.38,'WR06003')
  452. say "      WR06003 C C 1                                                 "
  453. say "  "MSG.39
  454. say
  455. say
  456. signal End
  457.  
  458.  
  459. /*****************************************************************/
  460. /* This routine will take a message and a variable and place the */
  461. /* variable in the proper position in the string.                */
  462. /*****************************************************************/
  463. Create_MSG:
  464. parse arg MESSAGE,VARIABLE
  465. PART1 = SUBSTR(MESSAGE,1,POS('%1',MESSAGE)-1)
  466. PART2 = SUBSTR(MESSAGE,POS('%1',MESSAGE)+2)
  467. RETURN PART1 || VARIABLE || PART2
  468.  
  469.  
  470. /*********************************************************************/
  471. /* This routine will take a message and two variables and place the  */
  472. /* variables in their proper positions in the string.                */
  473. /*********************************************************************/
  474. Create_MSG2:
  475. parse arg MESSAGE,VARIABLE1,VARIABLE2
  476. POS1 = POS('%1',MESSAGE)
  477. POS2 = POS('%2',MESSAGE)
  478. PART1 = SUBSTR(MESSAGE,1,POS1-1)
  479. PART2 = SUBSTR(MESSAGE,POS1+2,POS2-POS1-2)
  480. PART3 = SUBSTR(MESSAGE,POS2+2)
  481. RETURN PART1 || VARIABLE1 || PART2 || VARIABLE2 || PART3
  482.  
  483.  
  484. /*******************************************************************/
  485. /* This routine will take a message line from the message file     */
  486. /* and parse it into a message number and a text string            */
  487. /*******************************************************************/
  488. MSG_Parse:
  489. parse arg MESSAGE
  490. TEXT = SUBSTR(MESSAGE,POS(' ',MESSAGE)+1)
  491. message_number = SUBSTR(MESSAGE,1,POS(' ',MESSAGE)-1)
  492. RETURN TEXT
  493.  
  494.  
  495. End:
  496.